package com.example.demo.web;

import com.example.demo.config.annotation.TimeOutAnnotation;
import com.example.demo.result.BaseResult;
import com.example.demo.service.TimeOutTestService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @Author: njz
 * @Description:
 * @Date: create in 2022/7/4 16:20
 */
@RestController
@RequestMapping("/api/time")
@Api("timeout")
public class TimeOutTestController {

    @Resource
    private TimeOutTestService timeOutTestService;

    @GetMapping("/6s")
    public BaseResult test1() {
        try {
            return timeOutTestService.test1();
        } catch (InterruptedException e) {
            e.printStackTrace();
            return BaseResult.result(201,"controller异常");
        }
    }

    @GetMapping("/4s")
    public BaseResult test2(){
        try {
            return timeOutTestService.test2();
        } catch (InterruptedException e) {
            e.printStackTrace();
            return BaseResult.result(201,"controller异常");
        }
    }
}
